package com.diy.sigmund.diycommon.entity;

import com.diy.sigmund.diycommon.entity.base.AbstractEntity;
import com.diy.sigmund.diycommon.entity.enumerate.ResponseEnum;

/**
 * @author ylm-sigmund
 * @since 2022/6/11 12:29
 */
public class ResultMessage<T> extends AbstractEntity {

    private static final long serialVersionUID = 1L;
    /**
     * 状态码
     */
    private String code;
    /**
     * 响应消息
     */
    private String msg;
    /**
     * 消息负载
     */
    private T data;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ResultMessage() {
    }

    public ResultMessage(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResultMessage<T> failed(String message) {
        return new ResultMessage<>(ResponseEnum.INTERNAL_SERVER_BUSY.getCode(), message, null);
    }
}
